package com.sskj.xgja.mine;


import android.content.Context;
import android.content.Intent;
import android.widget.TextView;

import com.sskj.xgja.LiveDataBus;
import com.sskj.xgja.MVPActivity;
import com.sskj.base.data.User;
import com.sskj.base.view.ToolBarLayout;
import com.sskj.xgja.R;

import butterknife.BindView;

/**
 * @author Hey
 * Create at  2019/03/20
 */
public class AccountDetailActivity extends MVPActivity<AccountDetailPresenter> {

    @BindView(R.id.toolbar)
    ToolBarLayout toolbar;
    @BindView(R.id.account)
    TextView accountText;
    @BindView(R.id.currency)
    TextView currency;
    @BindView(R.id.total)
    TextView total;
    @BindView(R.id.available)
    TextView available;
    @BindView(R.id.useful)
    TextView useful;
    @BindView(R.id.percent)
    TextView percent;

    @Override
    public int getLayoutId() {
        return R.layout.activity_account_detail;
    }

    @Override
    public AccountDetailPresenter getPresenter() {
        return new AccountDetailPresenter();
    }

    @Override
    public void initView() {
        toolbar.setLeftButtonOnClickListener(v -> finish());
    }

    @Override
    public void initData() {
        mPresenter.getAccountDetail(account);
    }

    public static void start(Context context) {
        Intent intent = new Intent(context, AccountDetailActivity.class);
        context.startActivity(intent);
    }

    public void setAccountInfo(User data) {
        LiveDataBus.get().with(1,User.class).postValue(data);

//        userViewModel.setUser(this, data);
        setText(available, data.getWallone());
        setText(useful, data.getGuarantee_rate() + "%");
//        setText(percent, data.getStockUserInfo().getProportion());
        //        setText(total, data.getWallone());
        setText(accountText, account);
        setText(currency, data.getCoin_type());
    }
}
